package com.bianmaba.schedulings;

import com.bianmaba.jobs.DefaultJob;
import org.quartz.JobBuilder;
import org.quartz.JobDetail;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.quartz.CronTriggerFactoryBean;

/**
 * @program: samples
 * @description:
 * @author: Chenjiabin
 * @create: 2019/10/8 15:54
 **/
@Configuration
public class CronTriggerSchedule {

   // @Bean("cronTriggerFactoryBean")
    public CronTriggerFactoryBean simpleTriggerFactoryBean() {
        JobDetail jobDetail = JobBuilder.newJob(DefaultJob.class).withIdentity("cronTriggerFactoryBean")
                .usingJobData("description", "使用cron表达式的执行器，每5秒执行一次").build();

        CronTriggerFactoryBean trigger = new CronTriggerFactoryBean();
        trigger.setJobDetail(jobDetail);
        trigger.setCronExpression("0/5 * * * * ?");
        return trigger;
    }
}
